package com.demo.starter.web.api;

import com.demo.starter.entity.User;
import com.demo.starter.service.IUserService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/user")
@Log4j2
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/{id}")
    public User user(@PathVariable(name="id") Integer id) {
        log.debug("debug log...");
        log.info("info log...");
        log.warn("warn log...");
        log.error("error log...");

        final User user = userService.getById(id);

        return user;
    }

}
